﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UserManagement.aspx.cs" Inherits="AnalyseCRM.SystemSet.UserManagement" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>证券行业分析型客户关系管理之系统管理用户管理</title>
    <link href="../Styles/index.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/management.css" rel="stylesheet" type="text/css" />
    <link href="/Styles/common.css" rel="stylesheet" type="text/css" /> 
    <script type="text/javascript" src="../Scripts/Tab.js"></script>
    <script type="text/javascript" src="../Scripts/Markettab.js"></script>
    <script type="text/javascript" src="../Scripts/Common.js"></script>
    <!-- 下拉菜单美化 -->
    <script type="text/javascript" src="../Scripts/jquery-ui-1.9.1.custom/js/jquery-1.8.2.js"></script>
    <script type="text/javascript" src="../Scripts/divselect.js"></script>
    <script type="text/javascript">
        $(function () {
            BindDictSelect("4", "#userdepartment");
            BindDictSelect("5", "#userjob");
            $.divselect("#divselect", "#inputselect");
            var hh = document.documentElement.clientHeight;
            var tophh = $("#top1").height() + $("#top2").height()
                        + $("#bottom1").height() + $("#tags").height() + 10;
            $("#tagContent").height(hh - tophh);
            SearchQuery();
            SearchQueryRoles();
            SearchQueryUserByroleno();
        });
        function savenewuser() {
            $("#userinput input[type='text']").each(function () {
                if ($(this).val() == "") {
                    alert("请检查是否没有输入用户信息！");
                    return false;
                }
            });
            var pValue = $("#logname").val() + '|';
            pValue += $("#username").val() + '|';
            pValue += $("#logpass").val() + '|';
            pValue += $("#passques").val() + '|';
            pValue += $("#email").val() + '|';
            pValue += $("#reltelphone").val() + '|';
            pValue += $("#userdepartment").val() + '|';
            pValue += $("#userjob").val();
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/UserManagementAjax.aspx",
                data: "paramvalue=" + escape(pValue) + "&paramtype=InsertUsers",
                /*beforeSend: function () {
                $("#divprocess").show();
                },*/
                success: function (message) {
                    if (message == "SUCCESS") {
                        alert("保存用户成功！");
                        SearchQuery();
                    }
                    else {
                        alert("保存用户时发生异常！");
                    }
                },
                error: function () {
                    //$("#divpgtsh").html("连接服务是发生异常！");
                    alert("连接服务是发生异常！");
                }
            });
        }  // end of saveuser click
        function SearchQuery(cPage, pSize) {
            if (!arguments[0]) cPage = _cPage;
            if (!arguments[1]) pSize = _pSize;

            var foundstr = cPage + '|' + pSize;
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/UserManagementAjax.aspx",
                data: "paramvalue=" + escape(foundstr) + "&paramtype=getAccountList",
                /*beforeSend: function () {
                $("#divprocess").show();
                },*/
                success: function (message) {
                    if (message != "error") {
                        var arr = message.split("$");
                        BindQueryList(arr[0]);
                        //SetPager(cPage, arr[1], "#pager_container", pSize);
                    }
                    else {
                        alert("查询时发生异常！");
                    }
                },
                error: function () {
                    //$("#divpgtsh").html("连接服务是发生异常！");
                    alert("连接服务是发生异常！");
                }
            });
        } // end of SearchQuery 

        // 绑定查询记录
        function BindQueryList(message) {
            var oHtml = "";
            if (message == "none") { $("#search_result").html("<tr><td colspan=9>未查询到相关记录！</td></tr>"); return; }
            var list = eval("(" + message + ")").AccountMana;
            for (var i = 0; i < list.length; i++) {
                var data = list[i];
                oHtml += "<tr>";
                oHtml += "<td><input name=\"ckb_item\" id=\"ckb_item_" + data.username
                        + "\" type=\"checkbox\" value=\"" + data.username
                        + "\" onclick=\"resetuserclick('" + data.username + "');\"/></td>";
                oHtml += "<td style='text-align:right;'>" + data.username + "</td>";
                oHtml += "<td style='text-align:right;'>" + data.userrelname + "</td>";
                oHtml += "<td style='text-align:right;'>" + data.deptment + "</td>";
                oHtml += "<td style='text-align:right;'>" + data.userjob + "</td>";
                oHtml += "<td style='text-align:right;'>" + data.email + "</td>";
                oHtml += "<td>" + data.mobile + "</td>";
                oHtml += "<td>" + data.islock + "</td>";
                oHtml += "<td>" + data.isdelete + "</td>";
                oHtml += "<td>" + data.logdatetime + "</td>";
                oHtml += "</tr>";
            }
            jQuery("#search_result").html(oHtml);
        }

        function resetuserclick(user) {
            if ($("#ckb_item_" + user).attr("checked") == "checked") {
                $("#search_result input[type='checkbox']").each(function () {
                    $(this).attr("checked", false);
                    $("#ckb_item_" + user).attr("checked", true);
                });
            }
        }

        //删除用户
        function deleteUsers() {
            var user = $("#search_result input[type='checkbox']:checked").val();
            if ((user == "") | (user == null)) {
                alert("请选择要删除的用户！");
                return false;
            }
            if (confirm("确定要删除用户信息？")) {
                jQuery.ajax({
                    type: "POST",
                    url: "/InteractiveData/UserManagementAjax.aspx",
                    data: "paramvalue=" + escape(user) + "&paramtype=deleteAccount",
                    cache: false,
                    success: function (message) {
                        if (message == "SUCCESS") {
                            alert("用户删除成功！");
                            SearchQuery();
                        }
                        else {
                            alert("删除用户时发生异常!");
                        }
                    },
                    error: function () {
                        alert("服务器忙！");
                    }
                });
            }
        }
        /*=======================================重置用户密码======================================================*/
        function resetuserpass() {            
            var user = $("#search_result input[type='checkbox']:checked").val();
            if ((user == "") | (user == null)) {
                alert("请选择要重置密码的用户！");
                return false;
            }
            jQuery.ajax({
                type: "POST",
                url: "/InteractiveData/UserManagementAjax.aspx",
                data: "paramvalue=" + escape(user) + "&paramtype=resetuserpass",
                cache: false,
                success: function (message) {
                    if (message == "SUCCESS") {
                        alert("用户密码重置成功！");
                        SearchQuery();
                    }
                    else {
                        alert("重置用户密码时发生异常!");
                    }
                },
                error: function () {
                    alert("服务器忙！");
                }
            });
        }
        /*===========================================解锁===================================================*/
        function clearlockuser() {
            var user = $("#search_result input[type='checkbox']:checked").val();
            if ((user == "") | (user == null)) {
                alert("请选择要解锁的用户！");
                return false;
            }
            jQuery.ajax({
                type: "POST",
                url: "/InteractiveData/UserManagementAjax.aspx",
                data: "paramvalue=" + escape(user) + "&paramtype=clearlockforuser",
                cache: false,
                success: function (message) {
                    if (message == "SUCCESS") {
                        alert("用户解锁成功！");
                        SearchQuery();
                    }
                    else {
                        alert("为用户解锁时发生异常!");
                    }
                },
                error: function () {
                    alert("服务器忙！");
                }
            });
        }
        /*===========================================绑定两列的用户================================================*/
        function SearchQueryUserByroleno(roleno) {
            if ((roleno == "") | (roleno == null)) {
                roleno = "";
            }
            var pValue = roleno;
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/UserManagementAjax.aspx",
                data: "paramvalue=" + escape(pValue) + "&paramtype=getAllRolesListByrole",
                /*beforeSend: function () {
                $("#divprocess").show();
                },*/
                success: function (message) {
                    if (message != "error") {
                        var arr = message.split("$");
                        BindQueryListUser(arr[0]);
                    }
                    else {
                        alert("查询时发生异常！");
                    }
                },
                error: function () {
                    alert("连接服务是发生异常！");
                }
            });
        } // end of SearchQuery

        function BindQueryListUser(message) {
            var oHtml = "";
            if (message == "none") { $("#search_users").html("<tr><td colspan=3>未查询到相关记录！</td></tr>"); return; }
            var list = eval("(" + message + ")").SelectBindUsers;
            for (var i = 0; i < list.length; i++) {
                var data = list[i];
                oHtml += "<tr>";
                if (data.ischecked == 0) {
                    oHtml += "<td><input name=\"ckb_item\" id=\"ckb_item_r" + data.username
                        + "\" type=\"checkbox\" value=\"" + data.username
                        + "\" onclick=\"bindroleuserclick('" + data.username + "');\"/></td>";
                }
                else {
                    oHtml += "<td><input name=\"ckb_item\" id=\"ckb_item_r" + data.username
                        + "\" type=\"checkbox\" checked=\"checked\" value=\"" + data.username
                        + "\" onclick=\"bindroleuserclick('" + data.username + "');\"/></td>";
                }                       
                oHtml += "<td style='text-align:right;'>" + data.username + "</td>";
                oHtml += "<td style='text-align:left;'>" + data.userrelname + "</td>";               
                oHtml += "</tr>";
            }
            jQuery("#search_users").html(oHtml);
        }

        function SearchQueryRoles() {
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/UserManagementAjax.aspx",
                data: "paramvalue=&paramtype=getAllRolesList",
                /*beforeSend: function () {
                $("#divprocess").show();
                },*/
                success: function (message) {
                    if (message != "error") {
                        var arr = message.split("$");
                        BindQueryListRoles(arr[0]);
                    }
                    else {
                        alert("查询时发生异常！");
                    }
                },
                error: function () {
                    alert("连接服务是发生异常！");
                }
            });
        } // end of SearchQuery 

        // 绑定查询记录
        function BindQueryListRoles(message) {
            var oHtml = "";
            if (message == "none") { $("#search_roles").html("<tr><td colspan=3>未查询到相关记录！</td></tr>"); return; }
            var list = eval("(" + message + ")").RolesMana;
            for (var i = 0; i < list.length; i++) {
                var data = list[i];
                oHtml += "<tr>";
                oHtml += "<td><input name=\"ckb_item\" id=\"ckb_item_" + data.roleno.toLowerCase()
                        + "\" type=\"checkbox\" value=\"" + data.roleno
                        + "\" onclick=\"resetbindauthclick('" + data.roleno + "');\"/></td>";
                oHtml += "<td style='text-align:right;'>" + data.roleno + "</td>";
                oHtml += "<td style='text-align:right;'>" + data.rolename + "</td>";
                oHtml += "</tr>";
            }
            jQuery("#search_roles").html(oHtml);
        }

        function bindroleuserclick(username) {
            var pValue = "";
            var roleno = $("#search_roles input[type='checkbox']:checked").val();
            if ((roleno == "") | (roleno == null)) {
                alert("请选择要绑定的角色！");
                return false;
            }
            if ($("#ckb_item_r" + username).attr("checked") == "checked") {
                pValue = roleno + '|' + username + '|A';
            }
            else {
                pValue = roleno + '|' + username + '|D';
            }
            jQuery.ajax({
                type: "post",
                url: "/InteractiveData/UserManagementAjax.aspx",
                data: "paramvalue=" + escape(pValue) + "&paramtype=bindroleuserity",
                /*beforeSend: function () {
                $("#divprocess").show();
                },*/
                success: function (message) {
                    if (message == "SUCCESS") {
                        SearchQueryUserByroleno(roleno);
                        alert("操作成功！");
                    }
                    else {
                        if ($("#ckb_item_" + username).attr("checked") == "checked") {
                            alert("绑定角色和权限时发生异常！");
                        }
                        else {
                            alert("删除绑定角色和权限时发生异常！");
                        }
                    }
                },
                error: function () {
                    //$("#divpgtsh").html("连接服务是发生异常！");
                    alert("连接服务是发生异常！");
                }
            });
        } // end of bindrole
        function resetbindauthclick(roleno) {
            if ($("#ckb_item_" + roleno.toLowerCase()).attr("checked") == "checked") {
                SearchQueryUserByroleno(roleno);
                $("#search_roles input[type='checkbox']").each(function () {
                    $(this).attr("checked", false);
                    $("#ckb_item_" + roleno.toLowerCase()).attr("checked", true);
                });
            }
        }
    </script>
    <!-- 下拉菜单美化end -->
    <!-- dd menu -->
    <script type="text/javascript">
    <!--
        var timeout = 500;
        var closetimer = 0;
        var ddmenuitem = 0;

        // open hidden layer
        function mopen(id) {
            // cancel close timer
            mcancelclosetime();

            // close old layer
            if (ddmenuitem) ddmenuitem.style.visibility = 'hidden';

            // get new layer and show it
            ddmenuitem = document.getElementById(id);
            ddmenuitem.style.visibility = 'visible';

        }
        // close showed layer
        function mclose() {
            if (ddmenuitem) ddmenuitem.style.visibility = 'hidden';
        }

        // go close timer
        function mclosetime() {
            closetimer = window.setTimeout(mclose, timeout);
        }

        // cancel close timer
        function mcancelclosetime() {
            if (closetimer) {
                window.clearTimeout(closetimer);
                closetimer = null;
            }
        }

        // close layer when click-out
        document.onclick = mclose;

        function closeapp() {
            window.opener = null;
            window.open("", "_self");
            window.close();
        }
        function relogon() {
            document.location = '/Logon.aspx';
        }
    // -->
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="top1" class="indextop">
 <div class="indextopleft"><img alt="" src="../images/logo_03.png" width="44" height="44" /><a>证券行业分析型客户关系管理</a></div>
 <div class="indextopright">
  <ul>
   <li class="exit"><a href="javascript:void(0);" onclick="javascript:relogon();">退出</a></li>
   <li class="admin">admin</li>
  </ul>
 </div>
</div>
<div id="top2"><ul id="sddm">
	<li><a class="yonghu" href="UserManagement.aspx">用户管理</a></li>
    <li><a class="role" href="RoleManagement.aspx">角色管理</a></li><%-- onmouseover="mopen('m15')" onmouseout="mclosetime()"--%>
    <li><a class="competence" href="AuthorityManagement.aspx">权限管理</a></li><%-- onmouseover="mopen('m16')" onmouseout="mclosetime()"--%>
    <li class="meunxu"></li>
    <li><a class="xitong" href="ParameterManagement.aspx">参数配置</a></li><%-- onmouseover="mopen('m17')" onmouseout="mclosetime()"--%>
    <li><a class="journal" href="JournalManagement.aspx">日志管理</a></li><%-- onmouseover="mopen('m18')" onmouseout="mclosetime()"--%>
</ul></div>

<div class="clear"></div>
<div id="con">
  <ul id="tags">
    <li class="selectTag"><a onclick="selectTagsys('tagContent0',this)" 
  href="javascript:void(0)">新增用户</a> </li>
    <li><a onclick="selectTagsys('tagContent1',this)" 
  href="javascript:void(0)">用户列表</a> </li>
    <li><a onclick="selectTagsys('tagContent2',this)" 
  href="javascript:void(0)">用户与角色</a> </li>
  </ul>
  <div id="tagContent">
    <div class="tagContent selectTag" id="tagContent0">
     <div class="toplist">
     <ul>
      <li><a><strong>您当前所在的位置：</strong>系统管理 > 用户管理 > <strong>新增用户</strong></a></li>
     </ul>
     
    </div>
    <div style="clear:both"></div>
    <div class="wrapper">
    <!--风格一，sharp color1-->

    <div class="graysharp color3">
      <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> 
    <div class="content" id="by1">  
     <div class="graycontent-top"></div>
            <div style="clear:both"></div>
          <div class="managementbox">
          <div id="userinput" class="managementboxleft"><table class="managementbox_table">
          <tr>
            <td class="Even">登录名称：</td>
            <td class="odd"><input id="logname" name="input" type="text" class="tableinput" />
            <label style="color:Red;">*</label></td>
          </tr>
          <tr>
            <td class="Even">用户姓名：</td>
            <td class="odd"><input id="username" name="input" type="text" class="tableinput" />
            <label style="color:Red;">*</label></td>
          </tr>
          <tr>
            <td class="Even">登录密码：</td>
            <td class="odd"><input id="logpass" name="input" type="text" class="tableinput" />
            <label style="color:Red;">*</label></td>
          </tr>
          <tr>
            <td class="Even">密码问题：</td>
            <td class="odd"><input id="passques" name="input" type="text" class="tableinput" />
            <label style="color:Red;">*</label></td>
          </tr>
            <tr>
            <td class="Even">Email：</td>
            <td class="odd"><input id="email" name="input" type="text" class="tableinput" />
            <label style="color:Red;">*</label></td>
          </tr>
          <tr>
            <td class="Even">联系电话：</td>
            <td class="odd"><input id="reltelphone" name="input" type="text" class="tableinput" />
            <label style="color:Red;">*</label></td>
          </tr>
          <tr>
            <td class="Even">部门：</td>
            <td style="text-align:left;width: 66%;"><select id="userdepartment" class="selectinput"></select>  
            <label style="color:Red;">*</label></td>
          </tr>
          <tr>
            <td class="Even">职务：</td>
            <td style="text-align:left;width: 66%;"><select id="userjob" class="selectinput"></select>  
            <label style="color:Red;">*</label></td>
          </tr>
        </table>
        </div>
        <div class="managementboxright">
        </div>
        <div style="clear:both"></div>
        <span><input id="saveuser" class="managementinput" name="" 
                     type="button" value="保 存" onclick="javascript:savenewuser();"  /></span>
         </div>
       </div>
        <b class="b5"></b><b class="b6"></b><b class="b7"></b><b class="b8"></b>    
  </div>

<div style="clear:both"></div>    
</div></div>

    
         
<div class="tagContent" id="tagContent1">
     <div class="toplist">
     <ul>
      <li><a><strong>您当前所在的位置：</strong>系统管理 > 用户管理 > <strong>用户列表</strong></a></li>
     </ul>
     
    </div>
    <div style="clear:both"></div>
    <div class="wrapper">        
    <div class="graysharp color3">
      <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> 
    <div class="content" id="by2">  
     <div class="graycontent-top"></div>
            <div style="clear:both"></div>
               <div class="tablebox">
              <table class="tabler" id="hacker2" cellspacing="0">
              <tr class="trbj">
                <td class="DmpData1"></td>
                <td class="DmpData1">登录名称</td>
                <td class="DmpData1">用户姓名</td>
                <td class="DmpData1">部门</td>
                <td class="DmpData1">职务</td>
                <td class="DmpData1">EMAIL</td>
                <td class="DmpData1"><a>联系电话</a></td>
                <td class="DmpData1">是否锁定</td>
                <td class="DmpData1"><a>是否已删除</a></td>
                <td class="DmpData1"><a>创建用户时间</a></td>   
                </tr>
                <tbody id="search_result">
                </tbody>    
            </table>
    <div class="tablebottom">
    <input id="deluser" onclick="javascript:deleteUsers();" class="managementinput0" name="" type="button" value="删 除"  />
    <input id="resetuser" onclick="javascript:resetuserpass();" class="managementinput0" name="" type="button" value="重 置"  />
    <input id="unlockuser" onclick="javascript:clearlockuser();" class="managementinput0" name="" type="button" value="解 锁"  />
    <input id="copyauthor" class="managementinput0" name="" type="button" value="权限复制" /></div>
    </div>
                 </div>
        <b class="b5"></b><b class="b6"></b><b class="b7"></b><b class="b8"></b>    
  </div>

 
<div style="clear:both"></div>    
</div></div>
    
    
    
    <div class="tagContent" id="tagContent2">
     <div class="toplist">
     <ul>
      <li><a><strong>您当前所在的位置：</strong>系统管理 > 用户管理 > <strong>用户与角色</strong></a></li>
      
     </ul>
     
    </div>
    <div style="clear:both"></div>
    <div class="wrapper">
     <div class="graysharp color3">
      <b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b> 
    <div class="content" id="by3">  
     <div class="graycontent-top"></div>
            <div style="clear:both"></div>
  <div class="managementbox">
       <div class="managementboxleft">
        <table class="tabler" id="hacker1" cellspacing="0">
            <tr class="trbj">
                <td class="DmpData1"></td>
                <td class="DmpData1">角色编号</td>
                <td class="DmpData1">角色名称</td>
            </tr>
            <tbody id="search_roles">
            </tbody>  
        </table>
       </div>
<div class="managementboxright">
     <table class="tabler" id="hacker3" cellspacing="0">
     <tr class="trbj">
        <td></td>
        <td>登录名称</td>
        <td><a>用户名称</a></td>        
    </tr>
    <tbody id="search_users">
    </tbody>
    </table>
</div>
<div style="clear:both"></div>
<div class="managementbottominput">
<%--<input class="managementinput0" name="" type="button" border="0" value="用户绑定角色"  />
    <input class="managementinput0" name="" type="button" border="0" value="删除绑定"  />--%>
</div>
  </div>
                 </div>
        <b class="b5"></b><b class="b6"></b><b class="b7"></b><b class="b8"></b>    
  </div>
<div style="clear:both"></div>    
</div></div>
</div>
</div>


<div style="clear:both"></div>
<div id="bottom1" class="foot"><a>版权所有：深圳华策略科技有限公司</a></div>

    </form>
</body>
</html>
